package com.zmx.job.admin.enums;

import java.util.Objects;

/**
 * @Description: 分发策略枚举
 * @Author zhaomxr
 * @Date 2021-12-20 16:58
 */
public enum RoutStrategyEnum {

    RANDOM("random", "随机分发"),
    POLLING("polling", "轮询分发"),
    POLLINGWEIGHT("pollingweight", "轮询加权分发"),
    BESTPERFORMANCE("bestperformance", "最佳性能分发");

    private String code;
    private String desc;

    RoutStrategyEnum() {
    }

    RoutStrategyEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static RoutStrategyEnum getEnumByCode(String code) {
        for (RoutStrategyEnum routStrategyEnum : RoutStrategyEnum.values()) {
            if (Objects.equals(routStrategyEnum.code, code)) {
                return routStrategyEnum;
            }
        }
        return null;
    }
}
